2020-2021 Sunseeker Telemetry and Lighting System
lcd_e_ex1_4_mux.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //*****************************************************************************
71 //*****************************************************************************
72 #include "driverlib.h"
73 
74 void main(void)
75 {
76  // Hold watchdog
77  WDT_A_hold(WDT_A_BASE);
78 
79  //Port select XT1
80  GPIO_setAsPeripheralModuleFunctionInputPin(
81  GPIO_PORT_P4,
82  GPIO_PIN1 + GPIO_PIN2,
83  GPIO_PRIMARY_MODULE_FUNCTION
84  );
85 
86  //Set external frequency for XT1
87  CS_setExternalClockSource(32768);
88 
89  //Select XT1 as the clock source for ACLK with no frequency divider
90  CS_initClockSignal(CS_ACLK, CS_XT1CLK_SELECT, CS_CLOCK_DIVIDER_1);
91 
92  //Start XT1 with no time out
93  CS_turnOnXT1(CS_XT1_DRIVE_0);
94 
95  //clear all OSC fault flag
96  CS_clearAllOscFlagsWithTimeout(1000);
97 
98  /*
99  * Disable the GPIO power-on default high-impedance mode to activate
100  * previously configured port settings
101  */
102  PMM_unlockLPM5();
103 
104  // L0~L26 & L36~L39 pins selected
105  LCD_E_setPinAsLCDFunctionEx(LCD_E_BASE, LCD_E_SEGMENT_LINE_0, LCD_E_SEGMENT_LINE_26);
106  LCD_E_setPinAsLCDFunctionEx(LCD_E_BASE, LCD_E_SEGMENT_LINE_36, LCD_E_SEGMENT_LINE_39);
107 
108  LCD_E_initParam initParams = LCD_E_INIT_PARAM;
109  initParams.clockDivider = LCD_E_CLOCKDIVIDER_8;
110  initParams.muxRate = LCD_E_4_MUX;
111  initParams.segments = LCD_E_SEGMENTS_ENABLED;
112 
113  // Init LCD as 4-mux mode
114  LCD_E_init(LCD_E_BASE, &initParams);
115 
116  // LCD Operation - Mode 3, internal 3.08v, charge pump 256Hz
117  LCD_E_setVLCDSource(LCD_E_BASE, LCD_E_INTERNAL_REFERENCE_VOLTAGE, LCD_E_EXTERNAL_SUPPLY_VOLTAGE);
118  LCD_E_setVLCDVoltage(LCD_E_BASE, LCD_E_REFERENCE_VOLTAGE_3_08V);
119 
120  LCD_E_enableChargePump(LCD_E_BASE);
121  LCD_E_setChargePumpFreq(LCD_E_BASE, LCD_E_CHARGEPUMP_FREQ_16);
122 
123  // Clear LCD memory
124  LCD_E_clearAllMemory(LCD_E_BASE);
125 
126  // Configure COMs and SEGs
127  // L0, L1, L2, L3: COM pins
128  // L0 = COM0, L1 = COM1, L2 = COM2, L3 = COM3
129  LCD_E_setPinAsCOM(LCD_E_BASE, LCD_E_SEGMENT_LINE_0, LCD_E_MEMORY_COM0);
130  LCD_E_setPinAsCOM(LCD_E_BASE, LCD_E_SEGMENT_LINE_1, LCD_E_MEMORY_COM1);
131  LCD_E_setPinAsCOM(LCD_E_BASE, LCD_E_SEGMENT_LINE_2, LCD_E_MEMORY_COM2);
132  LCD_E_setPinAsCOM(LCD_E_BASE, LCD_E_SEGMENT_LINE_3, LCD_E_MEMORY_COM3);
133 
134  // Display "123456"
135  // LCD Pin8-Pin9 for '1'
136  LCD_E_setMemory(LCD_E_BASE, LCD_E_MEMORY_BLINKINGMEMORY_4, 0x60);
137 
138  // LCD Pin12-Pin13 for '2'
139  LCD_E_setMemory(LCD_E_BASE, LCD_E_MEMORY_BLINKINGMEMORY_6, 0xDB);
140 
141  // LCD Pin16-Pin17 for '3'
142  LCD_E_setMemory(LCD_E_BASE, LCD_E_MEMORY_BLINKINGMEMORY_8, 0xF3);
143 
144  // LCD Pin20-Pin21 for '4'
145  LCD_E_setMemory(LCD_E_BASE, LCD_E_MEMORY_BLINKINGMEMORY_10, 0x67);
146 
147  // LCD Pin4-Pin5 for '5'
148  LCD_E_setMemory(LCD_E_BASE, LCD_E_MEMORY_BLINKINGMEMORY_2, 0xB7);
149 
150  // LCD Pin36-Pin37 for '6'
151  LCD_E_setMemory(LCD_E_BASE, LCD_E_MEMORY_BLINKINGMEMORY_18, 0xBF);
152 
153  // Turn on LCD
154  LCD_E_on(LCD_E_BASE);
155 
156  // Enter LPM3.5
157  PMM_turnOffRegulator();
158  __bis_SR_register(LPM4_bits | GIE);
159 }
160 
void main(void)